#include <iostream>

using std::cout;
using std::endl;

int func2(int x, int y)
{
    return x + y;
}

int func3(int x, int y)
{
    return x * y;
}

int func4()
{
    return 400;
}

//函数指针
typedef int (*pFunc)(int, int);
/* using pFunc = int(); */

void test()
{
    //延迟函数的调用
    pFunc f = &func2;//注册回调函数
    //...
    //...
    //...
    cout << "f(1, 2) = " << f(1, 2) << endl;//回调函数的执行

    f = func3;
    cout << "f(10, 20) = " << f(10, 20) << endl;

    /* f = func4;//error */
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

